/*
package com.hsmw.api.controller.pub;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hsmw.api.mapper.HsmwUserMapper;
import com.hsmw.api.service.*;
import com.hsmw.api.utils.JSONUtils;
import com.hsmw.api.vo.*;
import com.htn.common.core.constant.*;
import com.htn.common.core.utils.StringUtils;
import com.hsmw.domain.*;
import com.hsmw.domain.vo.OrderPoolVO;

import java.io.File;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

public class OrderTimeTask extends TimerTask {

    private HsmwUserDriverService hsmwUserDriverService;

    private HsmwPhoneBindService hsmwPhoneBindService;

    private HsmwGpsService   hsmwGpsService;

    private HsmwUserMapper hsmwUserMapper;

    private HsmwOrderService hsmwOrderService;

    private HsmwVehicleService hsmwVehicleService;

    private HsmwOrderVehicleRequestService hsmwOrderVehicleRequestService;

    private static ConcurrentHashMap<String, List<OrderPoolVO>> orderPool;

    private OrderPoolVO orderPoolVO;

    private HsmwOrderVehicleRelationService hsmwOrderVehicleRelationService;
    private  HsmwOrderVehicleRequest vehicleRequest;
    private WebSocket webSocket;
    private HsmwOrder orderInfo;
    private HsmwOrderDistributeInfoService hsmwOrderDistributeInfoService;
    private RedisCache redisCache;
    public OrderTimeTask(RedisCache redisCache,HsmwOrderDistributeInfoService hsmwOrderDistributeInfoService, HsmwOrder orderInfo, WebSocket webSocket, HsmwOrderVehicleRelationService hsmwOrderVehicleRelationService, HsmwOrderVehicleRequest vehicleRequest, HsmwUserDriverService hsmwUserDriverService, HsmwUserMapper hsmwUserMapper, HsmwOrderService hsmwOrderService, HsmwVehicleService hsmwVehicleService, HsmwOrderVehicleRequestService hsmwOrderVehicleRequestService,
                         OrderPoolVO orderPoolVO, ConcurrentHashMap<String, List<OrderPoolVO>> orderPool,HsmwPhoneBindService hsmwPhoneBindService) {
        this.hsmwUserDriverService = hsmwUserDriverService;
        this.hsmwUserMapper = hsmwUserMapper;
        this.hsmwOrderService = hsmwOrderService;
        this.hsmwVehicleService = hsmwVehicleService;
        this.hsmwOrderVehicleRequestService = hsmwOrderVehicleRequestService;
        this.orderPoolVO = orderPoolVO;
        this.orderPool = orderPool;
        this.vehicleRequest = vehicleRequest;
        this.hsmwOrderVehicleRelationService = hsmwOrderVehicleRelationService;
        this.webSocket = webSocket;
        this.orderInfo = orderInfo;
        this.hsmwOrderDistributeInfoService = hsmwOrderDistributeInfoService;
        this.hsmwPhoneBindService=hsmwPhoneBindService;
        this.redisCache = redisCache;
    }

    @Override
    public void run() {
        System.out.println("订单id为" + vehicleRequest.getOrderId() + "处理执行时间 ==== " + new Date());
        System.out.println("orderPool.get(orderPoolVO.getRequestId())===" +redisCache.getCacheList(vehicleRequest.getId()).size());
        System.out.println("orderPool.get(orderPoolVO.getRequestId())===" +redisCache.getCacheList(vehicleRequest.getId()).toString());
        //选中的 非指定抢单人员列表
        List<OrderPoolVO> resVos = new ArrayList<>();

        //选中的 指定 抢单人员列表
        List<OrderPoolVO> appointResVos = new ArrayList<>();


        //未选中的 抢单人员列表
        List<OrderPoolVO> unVos = new ArrayList<>();

        List<OrderPoolVO> data = new ArrayList<>();
        //指定的车辆抢单
        List<OrderPoolVO> appointVos = new ArrayList<>();
        //非指定的车辆抢单
        List<OrderPoolVO> unAppointVos = new ArrayList<>();
        //指定的剩余接单数量
        int appointRemainVehicleNum= 0;
        //非 指定的剩余接单数量
        int remainVehicleNum=0;

        List<JSONObject> result = redisCache.getCacheList(vehicleRequest.getId());
        if(CollectionUtil.isNotEmpty(result)){
            data= JSONUtils.transferJSONToBean(result);
        }
        for(OrderPoolVO poolVO:data){
            if(poolVO.isAppointCompanyOrder()){
                appointVos.add(poolVO);
            }else {
                unAppointVos.add(poolVO);
            }
        }
        //选中的 抢单人员列表
        //开始处理派单逻辑
        List<OrderPoolVO> vos =data;
        List<HsmwOrderVehicleRelation> relationList = new ArrayList<>();
        //如果参与抢单的司机 数量小于该需求需要 的车辆数， 那么直接 分别为参与抢单的司机生成一个子订单信息
        //查询该需求最新的未结单车辆的数量
        HsmwOrderVehicleRequest hsmwOrderVehicleRequest= hsmwOrderVehicleRequestService.getById(vehicleRequest.getId());

        boolean appointFlag =false;
        boolean unAppointFlag =false;

        //如果非指定公司的 剩余接单数量 ==0 那么 非指定的车辆的司机都是失败的
        if( hsmwOrderVehicleRequest.getRemainVehicleNumber()==0){
            unAppointFlag=true;
            if (CollectionUtil.isNotEmpty(unAppointVos)) {
                for (OrderPoolVO poolVO : unAppointVos) {
                    //通过手机号进行长链接推送抢单成功的信息。
                    WebSocketReturnVO vo = new WebSocketReturnVO();
                    vo.setStatus(WebsocketTypeEnum.GRABBFAIL.getValue());
                    vo.setMessage("抢单失败");
                    String returnJson = JSONObject.toJSON(vo).toString();
                    webSocket.AppointSending(poolVO.getDriverUsername(), returnJson);
                    //抢单失败的推送
                    System.out.println("抢单失败的推送信息---returnJson=="+returnJson);
                    TencentPushUtils.pushMsg("很遗憾，抢单失败！", poolVO.getDriverUsername(),"has_new_message");
                }
            }
        }
        //如果 是 指定公司的 剩余接单数量 ==0 那么 指定的车辆的司机都是失败的
        if( hsmwOrderVehicleRequest.getRemainAppointVehicleNumber()==0){
            appointFlag=true;
            if (CollectionUtil.isNotEmpty(appointVos)) {
                for (OrderPoolVO poolVO : appointVos) {
                    //通过手机号进行长链接推送抢单成功的信息。
                    WebSocketReturnVO vo = new WebSocketReturnVO();
                    vo.setStatus(WebsocketTypeEnum.GRABBFAIL.getValue());
                    vo.setMessage("抢单失败");
                    String returnJson = JSONObject.toJSON(vo).toString();
                    webSocket.AppointSending(poolVO.getDriverUsername(), returnJson);
                    //抢单失败的推送
                    System.out.println("抢单失败的推送信息---returnJson=="+returnJson);
                    TencentPushUtils.pushMsg("很遗憾，抢单失败！", poolVO.getDriverUsername(),"has_new_message");
                }
            }
        }
        if(appointFlag && unAppointFlag){
            return;
        }
        //非指定司机的 剩余数量 不等于0
        if (hsmwOrderVehicleRequest.getRemainVehicleNumber()!=0 &&  unAppointVos.size() <= hsmwOrderVehicleRequest.getRemainVehicleNumber()) {
            for(OrderPoolVO orderPoolVO1 : unAppointVos){
                if (hsmwOrderVehicleRelationService.checkIfVehicleWorking(orderPoolVO1.getVehicleId())) {
                    resVos.add(orderPoolVO1);
                }
            }
        }
        //指定司机的 剩余数量 不等于0
        if (hsmwOrderVehicleRequest.getRemainAppointVehicleNumber()!=0 &&  appointVos.size() <= hsmwOrderVehicleRequest.getRemainAppointVehicleNumber()) {
            for(OrderPoolVO orderPoolVO1 : appointVos){
                if (hsmwOrderVehicleRelationService.checkIfVehicleWorking(orderPoolVO1.getVehicleId())) {
                    appointResVos.add(orderPoolVO1);
                }
            }
        }
        //如果非指定司机  参与抢单的司机 数量大于该需求需要 的车辆数， 那么 抢单人员要根据评分进行降序排列，然后取出所需要的个数
        if (unAppointVos.size() > hsmwOrderVehicleRequest.getRemainVehicleNumber()) {
            unAppointVos = sortByParam(unAppointVos, hsmwOrderVehicleRequest.getDistributeType());
            for (int i = 0; i < hsmwOrderVehicleRequest.getRemainVehicleNumber(); i++) {
                OrderPoolVO vo = unAppointVos.get(i);
                if (hsmwOrderVehicleRelationService.checkIfVehicleWorking(vo.getVehicleId())) {
                    resVos.add(vo);
                }
            }
            for (int i = hsmwOrderVehicleRequest.getRemainVehicleNumber(); i < unAppointVos.size(); i++) {
                OrderPoolVO vo = unAppointVos.get(i);
                unVos.add(vo);
            }
        }
        //如果 指定司机 参与抢单的 数量大于该需求需要 的车辆数， 那么 抢单人员要根据评分进行降序排列，然后取出所需要的个数
        if (appointVos.size() > hsmwOrderVehicleRequest.getRemainAppointVehicleNumber()) {
            appointVos = sortByParam(appointVos, hsmwOrderVehicleRequest.getDistributeType());
            for (int i = 0; i < hsmwOrderVehicleRequest.getRemainAppointVehicleNumber(); i++) {
                OrderPoolVO vo = appointVos.get(i);
                if (hsmwOrderVehicleRelationService.checkIfVehicleWorking(vo.getVehicleId())) {
                    appointResVos.add(vo);
                }
            }
            for (int i = hsmwOrderVehicleRequest.getRemainAppointVehicleNumber(); i < appointVos.size(); i++) {
                OrderPoolVO vo = appointVos.get(i);
                unVos.add(vo);
            }
        }
        if (CollectionUtil.isNotEmpty(resVos)) {
            List<String> hsmwUserNames = new ArrayList<>();
            //将过滤好的 抢单人员列表 分别生成一个子订单信息 并将子订单信息的状态埴为"已接单"
            for (OrderPoolVO poolVO : resVos) {
                HsmwOrderVehicleRelation relation = new HsmwOrderVehicleRelation();
                relation.setAcceptOrderTime(LocalDateTime.now());
                relation.setOrderStatus(ChildOrderStatusEnum.RECEIVED.getValue());
                relation.setOrderId(poolVO.getOrderId());
                relation.setDriverUsername(poolVO.getDriverUsername());
                relation.setDriverId(poolVO.getDriverId());
                relation.setVehicleNum(poolVO.getVehicleNum());
                relation.setOrderVehicleRequestId(poolVO.getRequestId());
                relation.setVehicleId(poolVO.getVehicleId());
                relation.setExpectVolume(poolVO.getExpectVolume());
                relation.setVehicleModel(poolVO.getVehicleModel());
                relation.setVehicleType(poolVO.getVehicleType());
                relation.setVehicleId(poolVO.getVehicleId());
                relation.setImeiNum(poolVO.getImeiNum());
                relation.setVehicleWorkStatus(CommonConstants.VEHICLE_WORK);
                relation.setDriverName(poolVO.getDriverName());
                relationList.add(relation);
                hsmwUserNames.add(poolVO.getDriverUsername());
            }

            hsmwOrderVehicleRelationService.saveBatch(relationList);
            //抢单成功以后 将  该订单发布信息置为 已接单
            HsmwOrderDistributeInfo info = new HsmwOrderDistributeInfo();
            info.setDistributeStatus(DistributeStatusEnum.RECEVIED.getValue());
            hsmwOrderDistributeInfoService.update(info, new LambdaQueryWrapper<HsmwOrderDistributeInfo>()
                    .in(HsmwOrderDistributeInfo::getVehicleId, resVos.stream().map(OrderPoolVO::getVehicleId).collect(Collectors.toSet()))
                    .in(HsmwOrderDistributeInfo::getOrderId, resVos.stream().map(OrderPoolVO::getOrderId).collect(Collectors.toSet())));
            //司机抢单成功 则 将 司机状态改为 工作中
            List<HsmwVehicle> vehicles = new ArrayList<>();
            List<HsmwUserDriver> drivers = new ArrayList<>();
            resVos.stream().forEach(orderPoolVO1 -> {
                HsmwVehicle vehicle = new HsmwVehicle();
                vehicle.setId(orderPoolVO1.getVehicleId());
                vehicle.setWorkStatus(CommonConstants.VEHICLE_WORK);
                vehicles.add(vehicle);
                List<HsmwUserDriver> driverss=hsmwUserDriverService.list(new LambdaQueryWrapper<HsmwUserDriver>()
                        .eq(HsmwUserDriver::getVehicleId,orderPoolVO1.getVehicleId()));
                if (CollectionUtil.isNotEmpty(driverss)){
                    driverss.stream().forEach(hsmwUserDriver -> {
                        HsmwUserDriver driver = new HsmwUserDriver();
                        driver.setId(hsmwUserDriver.getId());
                        driver.setWorkStatus(CommonConstants.DRIVER_WORK);
                        drivers.add(driver);
                    });
                }
            });
            hsmwUserDriverService.updateBatchById(drivers);
            //司机抢单成功 则 将 司机状态改为  工作中
            hsmwVehicleService.updateBatchById(vehicles);
            //通过websocket 长链接推送给客户端抢单成功的信息
            resVos.stream().forEach(orderPoolVO -> {
                //查询当前车辆下面的所有的司机并给他们推送信息
                List<HsmwUserDriver> driverss=hsmwUserDriverService.list(new LambdaQueryWrapper<HsmwUserDriver>()
                        .eq(HsmwUserDriver::getVehicleId,orderPoolVO.getVehicleId()));
                List<String> userIds =new ArrayList<>();
                if (CollectionUtil.isNotEmpty(driverss)){
                    driverss.stream().forEach(driv->{
                        userIds.add(driv.getUserId());
                    });
                    List<HsmwUser> users = hsmwUserMapper.selectBatchIds(userIds);
                    if(CollectionUtil.isNotEmpty(users)){
                        users.stream().forEach(user -> {
                            WebSocketReturnVO vo = new WebSocketReturnVO();
                            vo.setStatus(WebsocketTypeEnum.GRABBSUCC.getValue());
                            int month = orderInfo.getReachTime().getMonth().getValue();
                            int day = orderInfo.getReachTime().getDayOfMonth();
                            int hour = orderInfo.getReachTime().getHour();
                            int minute = orderInfo.getReachTime().getMinute();
                            String minutes ="";
                            if(0==minute){
                                minutes = "00";
                            }
                            String retMsg = "请于" + month + "月" + day + "日 " + hour + ":" + minutes + "之前到达指定地点";
                            vo.setMessage(retMsg);
                            //vo.setData(orderInfo);
                            String returnJson = JSONObject.toJSON(vo).toString();
                            System.out.println("returnJson" + returnJson);
                            //通过手机号进行长链接推送抢单成功的信息。
                            webSocket.AppointSending(user.getUsername(), returnJson);
                            TencentPushUtils.pushMsg("恭喜您,抢单成功！", user.getUsername(),"has_new_message");
                        });
                    }
                }


                //判断 当前订单的接单信息是否已经
            });
            //生成司机之间的虚拟号码
            //getDriversNum(resVos);
            //当符合条件的抢单人员人数小于 需求所需的人数 那么抢单完之后，需求人数 减去 参与的抢单的人数
            if (resVos.size() < hsmwOrderVehicleRequest.getVehicleNumber()) {
                remainVehicleNum=hsmwOrderVehicleRequest.getVehicleNumber() - resVos.size();
            }
            if (resVos.size() >= hsmwOrderVehicleRequest.getRemainVehicleNumber()) {
                hsmwOrderVehicleRequest.setRequestStatus(OrderReqStatusEnum.RELEASED.getValue());
                remainVehicleNum=0;
            }
        }
        if (CollectionUtil.isNotEmpty(appointResVos)) {
            List<String> hsmwUserNames = new ArrayList<>();
            //将过滤好的 抢单人员列表 分别生成一个子订单信息 并将子订单信息的状态埴为"已接单"
            for (OrderPoolVO poolVO : appointResVos) {
                HsmwOrderVehicleRelation relation = new HsmwOrderVehicleRelation();
                relation.setAcceptOrderTime(LocalDateTime.now());
                relation.setOrderStatus(ChildOrderStatusEnum.RECEIVED.getValue());
                relation.setOrderId(poolVO.getOrderId());
                relation.setDriverUsername(poolVO.getDriverUsername());
                relation.setDriverId(poolVO.getDriverId());
                relation.setVehicleNum(poolVO.getVehicleNum());
                relation.setOrderVehicleRequestId(poolVO.getRequestId());
                relation.setVehicleId(poolVO.getVehicleId());
                relation.setExpectVolume(poolVO.getExpectVolume());
                relation.setVehicleModel(poolVO.getVehicleModel());
                relation.setVehicleType(poolVO.getVehicleType());
                relation.setVehicleId(poolVO.getVehicleId());
                relation.setImeiNum(poolVO.getImeiNum());
                relation.setVehicleWorkStatus(CommonConstants.VEHICLE_WORK);
                relation.setDriverName(poolVO.getDriverName());
                relationList.add(relation);
                hsmwUserNames.add(poolVO.getDriverUsername());
            }

            hsmwOrderVehicleRelationService.saveBatch(relationList);
            //抢单成功以后 将  该订单发布信息置为 已接单
            HsmwOrderDistributeInfo info = new HsmwOrderDistributeInfo();
            info.setDistributeStatus(DistributeStatusEnum.RECEVIED.getValue());
            hsmwOrderDistributeInfoService.update(info, new LambdaQueryWrapper<HsmwOrderDistributeInfo>()
                    .in(HsmwOrderDistributeInfo::getVehicleId, appointResVos.stream().map(OrderPoolVO::getVehicleId).collect(Collectors.toSet()))
                    .in(HsmwOrderDistributeInfo::getOrderId, appointResVos.stream().map(OrderPoolVO::getOrderId).collect(Collectors.toSet())));
            //司机抢单成功 则 将 司机状态改为 工作中
            List<HsmwVehicle> vehicles = new ArrayList<>();
            List<HsmwUserDriver> drivers = new ArrayList<>();
            appointResVos.stream().forEach(orderPoolVO1 -> {
                HsmwVehicle vehicle = new HsmwVehicle();
                vehicle.setId(orderPoolVO1.getVehicleId());
                vehicle.setWorkStatus(CommonConstants.VEHICLE_WORK);
                vehicles.add(vehicle);
                List<HsmwUserDriver> driverss=hsmwUserDriverService.list(new LambdaQueryWrapper<HsmwUserDriver>()
                        .eq(HsmwUserDriver::getVehicleId,orderPoolVO1.getVehicleId()));
                if (CollectionUtil.isNotEmpty(driverss)){
                    driverss.stream().forEach(hsmwUserDriver -> {
                        HsmwUserDriver driver = new HsmwUserDriver();
                        driver.setId(hsmwUserDriver.getId());
                        driver.setWorkStatus(CommonConstants.DRIVER_WORK);
                        drivers.add(driver);
                    });
                }
            });
            hsmwUserDriverService.updateBatchById(drivers);
            //司机抢单成功 则 将 司机状态改为  工作中
            hsmwVehicleService.updateBatchById(vehicles);
            //通过websocket 长链接推送给客户端抢单成功的信息
            appointResVos.stream().forEach(orderPoolVO -> {
                //查询当前车辆下面的所有的司机并给他们推送信息
                List<HsmwUserDriver> driverss=hsmwUserDriverService.list(new LambdaQueryWrapper<HsmwUserDriver>()
                        .eq(HsmwUserDriver::getVehicleId,orderPoolVO.getVehicleId()));
                List<String> userIds =new ArrayList<>();
                if (CollectionUtil.isNotEmpty(driverss)){
                    driverss.stream().forEach(driv->{
                        userIds.add(driv.getUserId());
                    });
                    List<HsmwUser> users = hsmwUserMapper.selectBatchIds(userIds);
                    if (CollectionUtil.isNotEmpty(users)){
                        users.stream().forEach(user -> {
                            WebSocketReturnVO vo = new WebSocketReturnVO();
                            vo.setStatus(WebsocketTypeEnum.GRABBSUCC.getValue());
                            int month = orderInfo.getReachTime().getMonth().getValue();
                            int day = orderInfo.getReachTime().getDayOfMonth();
                            int hour = orderInfo.getReachTime().getHour();
                            int minute = orderInfo.getReachTime().getMinute();
                            String minutes ="";
                            if(0==minute){
                                minutes = "00";
                            }
                            String retMsg = "请于" + month + "月" + day + "日 " + hour + ":" + minutes + "之前到达指定地点";
                            vo.setMessage(retMsg);
                            //vo.setData(orderInfo);
                            String returnJson = JSONObject.toJSON(vo).toString();
                            System.out.println("returnJson" + returnJson);
                            //通过手机号进行长链接推送抢单成功的信息。
                            webSocket.AppointSending(user.getUsername(), returnJson);
                            TencentPushUtils.pushMsg("恭喜您,抢单成功！", user.getUsername(),"has_new_message");
                        });
                    }
                }
                //判断 当前订单的接单信息是否已经
            });
            //生成司机之间的虚拟号码
            //当符合条件的抢单人员人数小于 需求所需的人数 那么抢单完之后，需求人数 减去 参与的抢单的人数
            if (appointResVos.size() < hsmwOrderVehicleRequest.getRemainAppointVehicleNumber()) {
                appointRemainVehicleNum=hsmwOrderVehicleRequest.getRemainAppointVehicleNumber() - appointResVos.size();
            }
            if (appointResVos.size() >= hsmwOrderVehicleRequest.getRemainAppointVehicleNumber()) {
                hsmwOrderVehicleRequest.setRequestStatus(OrderReqStatusEnum.RELEASED.getValue());
                appointRemainVehicleNum=0;
            }
            //抢完单以后 ，将该抢单信息删除掉
            redisCache.deleteObject(orderPoolVO.getRequestId());
        }
        hsmwOrderVehicleRequest.setRemainAppointVehicleNumber(appointRemainVehicleNum);
        hsmwOrderVehicleRequest.setRemainVehicleNumber(remainVehicleNum);
        hsmwOrderVehicleRequestService.updateById(hsmwOrderVehicleRequest);
        //如果剩余的接单数量等于0  那么删除该需求下面的所有的已发布但是未接单信息
        if(0==appointRemainVehicleNum && 0==remainVehicleNum){
            hsmwOrderDistributeInfoService.remove(new LambdaQueryWrapper<HsmwOrderDistributeInfo>()
                    .eq(HsmwOrderDistributeInfo::getOrderVehicleRequestId,hsmwOrderVehicleRequest.getId())
                    .eq(HsmwOrderDistributeInfo::getDistributeStatus,DistributeStatusEnum.RELEASED.getValue()));
        }

        //抢完单以后 ，将该抢单信息从redis 中 删除掉
        redisCache.deleteObject(orderPoolVO.getRequestId());
        //接单后 判断该订单是否已经全部车辆接单
        RelationsInfo relationsInfo = hsmwOrderVehicleRelationService.checkIfComplete(hsmwOrderVehicleRequest.getOrderId());
        if(relationsInfo.isFlag()){
            String vehiclePaltes = "";
            String phoneNums = "";
            List<HsmwOrderVehicleRelation> relations=relationsInfo.getRelations();
            for(HsmwOrderVehicleRelation hsmwOrderVehicleRelation:relations){
                vehiclePaltes+=hsmwOrderVehicleRelation.getVehicleNum();
                phoneNums+=hsmwOrderVehicleRelation.getDriverUsername();
            }
            HsmwOrder order = hsmwOrderService.getById(hsmwOrderVehicleRequest.getOrderId());
            //推送 工长信息变化
            WXPushVO vo = new WXPushVO();
            vo.setMainTitle(PushOrderStatusEnum.UNRECEIVED.getName());
            vo.setOrderId(hsmwOrderVehicleRequest.getOrderId());
            vo.setConstructionAddress(order.getItemPositionDetail());
            vo.setVehicleNums(vehiclePaltes);
            vo.setArriveTime(order.getReachTime());
            vo.setOpenId(relationsInfo.getForemanOpenId());
            vo.setTemplateId(CommonConstants.WX_FOREMEN_TEMP_ID);
            WeapPushUtils.pushForemanMsg(vo,null);
        }
        //未接到订单的人如果不为空 则推送抢单失败的信息
        if (CollectionUtil.isNotEmpty(unVos)) {
            for (OrderPoolVO poolVO : unVos) {
                //通过手机号进行长链接推送抢单成功的信息。
                WebSocketReturnVO vo = new WebSocketReturnVO();
                vo.setStatus(WebsocketTypeEnum.GRABBFAIL.getValue());
                vo.setMessage("抢单失败");
                String returnJson = JSONObject.toJSON(vo).toString();
                webSocket.AppointSending(poolVO.getDriverUsername(), returnJson);
                //抢单失败的推送
                System.out.println("抢单失败的推送信息---returnJson=="+returnJson);
                TencentPushUtils.pushMsg("很遗憾，抢单失败！", poolVO.getDriverUsername(),"has_new_message");
            }
        }

    }


    public static List<OrderPoolVO> sortByParam(List<OrderPoolVO> vos, String orderType) {
        if (leasingCompanyTypeEnum.SELFSUPPORT.getValue().equals(orderType)) {
            //如果选择的是
            Collections.sort(vos, new Comparator<OrderPoolVO>() {
                @Override
                public int compare(OrderPoolVO v1, OrderPoolVO v2) {
                    if (!v2.getLeasingCompanyType().equals(v1.getLeasingCompanyType())) {
                        return Integer.parseInt(v1.getLeasingCompanyType()) - Integer.parseInt(v2.getLeasingCompanyType());
                    } else {
                        if (v2.getScore() != v1.getScore()) {
                            return Integer.parseInt(v2.getScore()) - Integer.parseInt(v1.getScore());
                        } else {
                            return v2.getGrabTime().compareTo(v1.getGrabTime());
                        }
                    }


                }
            });
        }
        if (leasingCompanyTypeEnum.UNSELFSUPPORT.getValue().equals(orderType)) {
            //如果选择的是
            Collections.sort(vos, new Comparator<OrderPoolVO>() {
                @Override
                public int compare(OrderPoolVO v1, OrderPoolVO v2) {
                    if (!v2.getLeasingCompanyType().equals(v1.getLeasingCompanyType())) {
                        return Integer.parseInt(v2.getLeasingCompanyType()) - Integer.parseInt(v1.getLeasingCompanyType());
                    } else {
                        if (v2.getScore() != v1.getScore()) {
                            return Integer.parseInt(v2.getScore()) - Integer.parseInt(v1.getScore());
                        } else {
                            return v2.getGrabTime().compareTo(v1.getGrabTime());
                        }
                    }
                }
            });
        }
        if (leasingCompanyTypeEnum.NOTLIMITED.getValue().equals(orderType)) {
            //如果选择的是
            Collections.sort(vos, new Comparator<OrderPoolVO>() {
                @Override
                public int compare(OrderPoolVO v1, OrderPoolVO v2) {
                    if (v2.getScore() != v1.getScore()) {
                        return Integer.parseInt(v2.getScore()) - Integer.parseInt(v1.getScore());
                    } else {
                        return v2.getGrabTime().compareTo(v1.getGrabTime());
                    }
                }
            });
        }
        if (StringUtils.isBlank(orderType)) {
            //如果选择的是
            Collections.sort(vos, new Comparator<OrderPoolVO>() {
                @Override
                public int compare(OrderPoolVO v1, OrderPoolVO v2) {
                    if (v2.getScore() != v1.getScore()) {
                        return Integer.parseInt(v2.getScore()) - Integer.parseInt(v1.getScore());
                    } else {
                        return v2.getGrabTime().compareTo(v1.getGrabTime());
                    }
                }
            });
        }
        return vos;
    }


    public  void getDriversNum( List<OrderPoolVO> numbers) {
        for (int i = 0; i < numbers.size() ; i++) {
            for (int j = i+1; j < numbers.size() ; j++) {
                System.out.println(numbers.get(i));
                //对电话号码进行加密处理
                //首先是司机于司机之间的电话的加密
                OrderPoolVO voa= numbers.get(i);
                OrderPoolVO vob= numbers.get(j);
                XuniTelNumVO param = new XuniTelNumVO();
                param.setPhoneA(voa.getDriverUsername());
                param.setPhoneB(vob.getDriverUsername());
                XuniTelNumVO vo = IACasClientUtils.bindAxb(param);
                if(null!=vo){
                    HsmwPhoneBind bind = new HsmwPhoneBind();
                    bind.setPhoneFirst(vo.getPhoneA());
                    bind.setPhoneSecond(vo.getPhoneB());
                    bind.setSecretNo(vo.getSecretNo());
                    bind.setOrderId(voa.getOrderId());
                    bind.setSubSid(vo.getSubsId());
                    hsmwPhoneBindService.save(bind);
                }
            }
        }
    }




    //获得不重复的文件名
    public static String getUUIDString() {
        String uuid = UUID.randomUUID().toString().replace("-", "").substring(0, 32);
        return uuid;
    }

    public static void updateFileNames(String url) {
        File file = new File(url);
        //判断文件目录是否存在，且是文件目录，非文件
        if (file.exists() && file.isDirectory()) {
            File[] fileList= file.listFiles();
            String path = file.getAbsolutePath();
            for (File childFile : fileList) {
                //如果是文件
                if (childFile.isFile()) {
                    String oldName = childFile.getName();
                    System.out.println(oldName);
                    oldName = oldName.replaceAll("【淘店：天天乐活】","");
                    childFile.renameTo(new File(path + "\\"+oldName));
                }else{
                    comFiles(childFile);
                }
            }
        }
    }

    public static void  comFiles(File file){
        if (file.exists() && file.isDirectory()) {
            File[] fileList= file.listFiles();
            String path = file.getAbsolutePath();
            for (File childFile : fileList) {
                //如果是文件
                if (childFile.isFile()) {
                    String oldName = childFile.getName();
                    System.out.println(oldName);
                    oldName = oldName.replaceAll("【淘店：天天乐活】","");
                    childFile.renameTo(new File(path + "\\"+oldName));
                }else{

                }
            }
        }
    }

    public static void main(String[] args) {

        List<OrderPoolVO> vos = new ArrayList<>();
        OrderPoolVO vo1 = new OrderPoolVO();
        vo1.setScore("500");
        vos.add(vo1);
        OrderPoolVO vo2 = new OrderPoolVO();
        vo2.setScore("501");
        vos.add(vo2);
        Collections.sort(vos, new Comparator<OrderPoolVO>() {
            @Override
            public int compare(OrderPoolVO v1, OrderPoolVO v2) {
                if (v2.getScore() != v1.getScore()) {
                    return Integer.parseInt(v2.getScore()) - Integer.parseInt(v1.getScore());
                } else {
                    return v2.getGrabTime().compareTo(v1.getGrabTime());
                }
            }
        });

        System.out.println(vos.get(0));

    }

}*/
